<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <a href="https://www.bilibili.com/video/BV1MN411y7pw?p=5&vd_source=480c28921b1b6c12cb33e4a6f0a94947">学习视频</a>
    <p>省份名字</p>
    <input type="text" class="n1">
    <p>城市名字</p>
    <input type="text" class="n2"><br>
    <button type="button" style="margin: 20px">查询</button>
    <p>地区列表:</p>
    <div class="pp" style="border: 2px solid black; width:100px"></div>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
        //检测点击行为
        document.querySelector('button').addEventListener('click', () => {
            let pName = document.querySelector('.n1').value;
            let cName = document.querySelector('.n2').value;
            axios({
                url: 'http://hmajax.itheima.net/api/area',
                params: {
                    pname: pName,
                    cname: cName
                }
            }).then(result => {
                console.log(result);
                //插入到页面
                document.querySelector('.pp').innerHTML = result.data.list.join('<br>');
            })
        })

    </script>
</body>

</html>